package learningThread.syn.synchronizedMethodLockObj.communicate.ThreadLocal.integer;

/**
 * 测试ThreadLocal
 * ThreadLocal是以当前线程对象作为key ,以变量作为值进行存储的
 *
 */
public class Run {

    public static ThreadLocal t11 = new ThreadLocal();

    public static void main(String[] args) {
//        if (t11.get() == null) {
//            System.out.println("从未放过值");
//            t11.set("我的值");
//        }
//        System.out.println(t11.get());
//        System.out.println(t11.get());

        try {
            ThreadA threadA = new ThreadA();
            ThreadB threadB = new ThreadB();
            threadA.start();
            threadB.start();
            for (int i = 0; i < 100; i++) {
                Tools.t1.set("Main"+(i+1));
                System.out.println("Main get value="+Tools.t1.get());
                Thread.sleep(200);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
